﻿Public Class FormGTGBMHJCRecord
    Dim objGTGBMHJC As New clsGTGBMHJC
    Dim txt As TextBox
    Private Sub FormGTGBMHJCRecord_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim startDate As String = Date.Now.AddDays(-1).ToShortDateString()
        txtStartDate.Text = startDate
        Dim endDate As String = Date.Now.ToShortDateString()
        txtEndDate.Text = endDate
        setDgvData()
    End Sub

    Private Sub btnSearce_Click(sender As Object, e As EventArgs) Handles btnSearce.Click
        setDgvData()
    End Sub

    Public Sub setDgvData()
        If String.IsNullOrEmpty(txtStartDate.Text.Trim()) = False And String.IsNullOrEmpty(txtEndDate.Text.Trim()) = False Then
            Dim dtGt As DataTable = objGTGBMHJC.getList(txtStartDate.Text.Trim() + " 00:00:00.000", txtEndDate.Text.Trim() + " 23:59:59.999")
            dgv.AutoGenerateColumns = False
            dgv.DataSource = dtGt
        Else
            MsgBox("请输入开始时间和结束时间")
        End If
    End Sub

    Private Sub dgv_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.CellDoubleClick
        If e.RowIndex > -1 And e.ColumnIndex > -1 Then
            Dim sysid As String = dgv.SelectedRows(0).Cells("sys_id").Value.ToString()
            Dim frmJLJC As New FormGTGBMHJC()
            frmJLJC.Sys_id = sysid
            frmJLJC.ShowDialog(Me)
        End If
    End Sub

    Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs) Handles txtStartDate.MouseClick, txtEndDate.MouseClick
        txt = CType(sender, TextBox)
        DateNavigator1.Left = txt.Left
        DateNavigator1.Top = txt.Location.Y + txt.Height
        DateNavigator1.Visible = True
    End Sub

    Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs) Handles DateNavigator1.DateTimeChanged
        txt.Text = DateNavigator1.DateTime.ToShortDateString()
        DateNavigator1.Visible = False
    End Sub

End Class